function tianjia() {
    var name = $("#name").val();
    var email = $("#email").val();
    var password = $("#password").val();
    var phone = $("#phone").val();
    //判断输入框不为空
    if(name==""||name==null){
        $("#namediv").addClass("form-group  has-error");
        document.getElementById("nameddd").style.display="block";
        return;
    }else if(email==""||email==null){
        $("#emaildiv").addClass("form-group  has-error");
        document.getElementById("emailddd").style.display="block";
        return;
    }else if(password==""||password==null){
        $("#passdiv").addClass("form-group  has-error");
        document.getElementById("passddd").style.display="block";
        return;
    }else if(phone==""||phone==null){
        $("#phonediv").addClass("form-group  has-error");
        document.getElementById("phoneddd").style.display="block";
        return;
    }
    var user = {};
    user.loginId = name;
    user.name = name;
    user.pass = password;
    user.phone = phone;
    user.email = email;
    /*var roleInfo = {};
    roleInfo.id = 2;
    user.roleInfo = roleInfo;*/

    $.ajax({
        type: 'post',
        url: "/user/add",
        contentType: 'application/json;charset=utf-8',
        data:JSON.stringify(user),
        success: function(data){    //请求成功时的回调函数
            if(data.code == "1"){
                window.location.href="/main-page";
            }else{
                alert(data.msg + data.data);
            }
        },
    });
}
//判断用户名是否重复
$("#name").blur(function () {
    var name = $("#name").val();
    $.ajax({
        type: 'get',
        url: "/user/allow/"+name,
        contentType: 'application/json;charset=utf-8',
        success: function(data){    //请求成功时的回调函数
            if(data.code == "1"){
                //window.location.href="/main-page";
                $("#namediv").removeClass("has-error");
                document.getElementById("nameddd").style.display="none";
                document.getElementById("namedd").style.display="none";
            }else{
                $("#name").val("");
                $("#namediv").addClass("form-group  has-error");
                document.getElementById("nameddd").style.display="none";
                document.getElementById("namedd").style.display="block";
            }
        },
    });
});